<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import="com.pmsco.pms.core.constant.PmsConstant"%>
<%@ page import="com.pmsco.pms.util.BundleUtil"%>
<%@ include file="/WEB-INF/import/tagLibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<script>
	    $(function() {
	        $("button").button();
	    });
    </script>
</head>
<body class="pmsMainBody">
	<table class="pmsMainTable">
		<tr class="pmsMainTableWrapperTd">
			<td>
			    <table class="tableForm">
			    	<input type="hidden" id="id" name="id" value="${command.id}"/>
			    	<input type="hidden" id="oldParentId" name="oldParentId" value="${command.parent.id}"/>
			    	<c:if test="${errorMessage != null}">
			    		<tr><td colspan="2" class="tableFormLabelRequired"><spring:message code="${errorMessage}"/></td></tr>	
			    	</c:if>
					<tr>
						<td class="tableFormLabel"><label class="tableFormLabelRequired">*&nbsp;</label><spring:message code="menu.name"/></td>
						<td><input type="text" class="talbeFormTextBox" id="name" name="name" value="${command.name}" size="50" required/></td>
					</tr>
					<tr>
						<td class="tableFormLabel"><spring:message code="menu.url"/></td>
						<td><input type="text" class="talbeFormTextBox" id="url" name="url" value="${command.url}" size="50"/></td>
					</tr>
					<tr>
						<td class="tableFormLabel"><spring:message code="menu.isLogonRequired"/></td>
						<td><input type="checkbox" class="talbeFormTextBox" id="isLogonRequired" name="isLogonRequired" <c:if test="${command.isLogonRequired == 'T'}"> checked="checked" </c:if> size="15"/></td>
					</tr>
					<tr>
						<td class="tableFormLabel"><spring:message code="menu.isTopLevel"/></td>
						<td><input type="checkbox" class="talbeFormTextBox" id="isTopLevel" name="isTopLevel" <c:if test="${command.isTopLevel == 'T'}"> checked="checked" </c:if> size="50"/></td>
					</tr>
					<tr>
						<td class="tableFormLabel"><spring:message code="menu.parent"/></td>
						<td>
							<select id="parentId" name="parentId">
								<option value="0" ${command.parent.id == nulll ? "selected" : ""}></option>
								<c:forEach var="parentItem" items="${parentMenuList}">
									<c:if test="${parentItem.id != command.id}">
										<option value="${parentItem.id}" ${parentItem.id == command.parent.id ? "selected" : ""}>${parentItem.name}</option>
									</c:if>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<td class="tableFormLabel" valign="top"><spring:message code="menu.roleEnable"/></td>
						<td>
							<table cellpadding="0" cellspacing="0">
								<c:forEach var="roleItem" items="${roleList}">
									<c:set var="enable" value="false"/>
									<c:forEach var="roleEnableItem" items="${roleEnableList}">
										<c:if test="${roleEnableItem.role.id == roleItem.id}">
											<c:set var="enable" value="true"/>
											<tr>
												<td>
													<input type="checkbox" name="enableRole" value="${roleItem.id}" id="role${roleItem.id}" checked="checked"/><label for="role${roleItem.id}">${roleItem.description}</label>
												</td>
											</tr>
										</c:if>
									</c:forEach>
									<c:if test="${enable == false}">
										<tr>
											<td>
												<input type="checkbox" name="enableRole" value="${roleItem.id}" id="role${roleItem.id}"/><label for="role${roleItem.id}">${roleItem.description}</label>
											</td>
										</tr>
									</c:if>
								</c:forEach>
							</table>
						</td>
					</tr>
					<tr>
						<td class="tableFormLabel"><label class="tableFormLabelRequired">*&nbsp;</label><spring:message code="menu.orderId"/></td>
						<td><input type="text" class="talbeFormTextBox" id="orderId" name="orderId" value="${command.orderId}" size="15" required/></td>
					</tr>
					<tr>
						<td colspan="2">
							<table align="center">
								<tr>
									<td>
										<button class="tableFormButton" onclick="return submitAction('<%=PmsConstant.saveMenu_JspUrl%>', true)"><spring:message code="button.save"/></button>
									</td>
									<td>
										<button class="tableFormButton" onclick="return confirmAction('<%=PmsConstant.listMenu_JspUrl%>', cancelMenuDetailTitle, cancelMenuDetailMessage)"><spring:message code="button.cancel"/></button>
									</td>
								</tr>
							</table>
						</td>
					</tr>	
				</table>
			</td>
		</tr>
	</table>
</body>
</html>